package cn.jiahua.dto;

public class ResponseDtoUtil {

    public static ResponseDto success(){
        ResponseDto<Object> dto = new ResponseDto<>();
        dto.setSuccess(true);
        return dto;
    }

    public static ResponseDto success(String msg){
        ResponseDto<Object> dto = new ResponseDto<>();
        dto.setSuccess(true);
        dto.setMsg(msg);
        return dto;
    }

    public static ResponseDto success(String msg, Object data){
        ResponseDto<Object> dto = new ResponseDto<>();
        dto.setSuccess(true);
        dto.setMsg(msg);
        dto.setData(data);
        return dto;
    }


    public static ResponseDto fail(ErrorCode errorCode){
        ResponseDto<Object> dto = new ResponseDto<>();
        dto.setSuccess(false);
        dto.setMsg(errorCode.getMsg());
        dto.setData(errorCode.getCode());
        return dto;
    }
}
